package com.wlj.threadpooldemo;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.ThreadFactory;

/**
 * @Author lijian.wu
 * @Date 2021/5/4 9:55 下午
 */
public class ThreadPoolEx {

    private static Logger logger= LoggerFactory.getLogger(ThreadPoolEx.class);

    public static void main(String[] args) {
        // 线程工厂，用于为线程池中的每条线程命名
        ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
                .setNameFormat("stats-pool-%d")
                .setUncaughtExceptionHandler((thread, throwable)-> logger.error("ThreadPool {} got exception", thread,throwable))
                .build();
        // 创建线程池，使用有界阻塞队列防止内存溢出

    }
}
